<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			var massages=[];
			var fun1=function(){
				massages=[];
				document.getElementById("name").value="";
				document.getElementById("word").value="";
				document.getElementById("words").value="";
			}
			var fun2=function(){
				var name=document.getElementById("name").value;
				var word=document.getElementById("word").value;
				var str="["+name+"]说："+word+"";
				massages.unshift(str);
				if(massages.length>10){
					massages.pop();
				}
				document.getElementById("words").value=massages.join("\n");
			}
		</script>
	</head>
	<body>
		姓名：<input type="text" id="name"><br>
		留言：<textarea rows="3" cols="30" id="word"></textarea><br>
		<button onclick="fun1()">重置</button>
		<button onclick="fun2()">留言</button>
		<hr>
		<textarea rows="10" cols="60" id="words"></textarea>
	</body>
</html>
